package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.FlightOrderAddressPost;
import com.ktgj.flight.service.IFlightOrderAddressPostService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 航信行程单地址Controller
 * 
 * @author ruoyi
 * @date 2021-10-26
 */
@ControllerAdvice
@RestController
@RequestMapping("/post")
public class FlightOrderAddressPostController extends BaseController
{
    @Autowired
    private IFlightOrderAddressPostService flightOrderAddressPostService;

    /**
     * 查询航信行程单地址列表
     */
    @PreAuthorize(hasPermi = "flight:post:list")
    @GetMapping("/list")
    public TableDataInfo list(FlightOrderAddressPost flightOrderAddressPost)
    {
        startPage();
        List<FlightOrderAddressPost> list = flightOrderAddressPostService.selectFlightOrderAddressPostList(flightOrderAddressPost);
        return getDataTable(list);
    }

    /**
     * 导出航信行程单地址列表
     */
    @PreAuthorize(hasPermi = "flight:post:export")
    @Log(title = "航信行程单地址", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlightOrderAddressPost flightOrderAddressPost) throws IOException
    {
        List<FlightOrderAddressPost> list = flightOrderAddressPostService.selectFlightOrderAddressPostList(flightOrderAddressPost);
        ExcelUtil<FlightOrderAddressPost> util = new ExcelUtil<FlightOrderAddressPost>(FlightOrderAddressPost.class);
        util.exportExcel(response, list, "航信行程单地址数据");
    }

    /**
     * 获取航信行程单地址详细信息
     */
    @PreAuthorize(hasPermi = "flight:post:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(flightOrderAddressPostService.selectFlightOrderAddressPostById(id));
    }

    /**
     * 新增航信行程单地址
     */
    @PreAuthorize(hasPermi = "flight:post:add")
    @Log(title = "航信行程单地址", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlightOrderAddressPost flightOrderAddressPost)
    {
        return toAjax(flightOrderAddressPostService.insertFlightOrderAddressPost(flightOrderAddressPost));
    }

    /**
     * 修改航信行程单地址
     */
    @PreAuthorize(hasPermi = "flight:post:edit")
    @Log(title = "航信行程单地址", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlightOrderAddressPost flightOrderAddressPost)
    {
        return toAjax(flightOrderAddressPostService.updateFlightOrderAddressPost(flightOrderAddressPost));
    }

    /**
     * 删除航信行程单地址
     */
    @PreAuthorize(hasPermi = "flight:post:remove")
    @Log(title = "航信行程单地址", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(flightOrderAddressPostService.deleteFlightOrderAddressPostByIds(ids));
    }
}
